package N3;

import java.util.Scanner;

// 定义比较接口ICompare
interface ICompare {
}

// 定义圆形类Circle，实现ICompare接口
class Circle implements ICompare {
    private final double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    public int compare(Object obj) {
        if (obj instanceof Circle other) {
            return Double.compare(this.radius, other.radius);
        } else {
            throw new IllegalArgumentException("比较的对象必须是 Circle 类型");
        }
    }
}

// 主类
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double radius1;
        double radius2;

        try {
            System.out.print("请输入第一个圆的半径：");
            radius1 = scanner.nextDouble();
            System.out.print("请输入第二个圆的半径：");
            radius2 = scanner.nextDouble();
        } catch (Exception e) {
            System.out.println("输入无效，请输入有效的数字！");
            scanner.close();
            return;
        }

        Circle circle1 = new Circle(radius1);
        Circle circle2 = new Circle(radius2);

        try {
            int result = circle1.compare(circle2);
            if (result > 0) {
                System.out.println("第一个圆大");
            } else if (result < 0) {
                System.out.println("第二个圆大");
            } else {
                System.out.println("两个圆一样大");
            }
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }

        scanner.close();
    }
}